package com.tionsy.springbootcomponents.repository;

import com.tionsy.springbootcomponents.bean.Person;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;

import java.util.List;

/**
 * @program: neo4j-demo
 * @description:
 * @author: Jamie.shi
 * @create: 2020-05-27 10:37
 **/
public interface PersonRepository extends Neo4jRepository<Person, Long> {
    /**
     * 返回某个人的所有朋友
     * @param name
     * @return
     */
    @Query("MATCH p =(n:Person)-[r:FRIEND]->(m:Person) WHERE m.name=$name RETURN n")
    List<Person> findFriendByPerson(String name);
    /**
     * 根据名字查找
     * @param name
     * @return
     */
    Person findByName(String name);
}
